package com.mstarc.app.mnfc;

import android.app.Activity;
import android.os.Bundle;

import com.alibaba.fastjson.JSON;
import com.mstarc.app.mnfc.okhttp.OKHttpResult;
import com.mstarc.app.mnfc.okhttp.OkHttpRequest;

/**
 * Created by qdyouke01 on 2017/7/3.
 */
public abstract class BaseActivity extends Activity implements OKHttpResult {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void requestJsonOnError(int msgFlag) {

    }

    @Override
    public void requestJsonOnSucceed(String json, int msgFlag) {

    }

    @Override
    public void requestJsonOnLocalError(int msgFlag) {

    }

    protected String getHttpParams(Object object) {
        return JSON.toJSONString(object);
    }


    protected void startRequest(String httpUrl, int msgFlg) {
        OkHttpRequest.getInstance(this).getHttp(httpUrl, msgFlg);
    }

    @SuppressWarnings("unchecked")
    protected <T> T getTByJsonString(String str, Class<?> clas) {
        return (T) JSON.parseObject(str, clas);
    }
}
